s = input().split(" ")
year = int(s[0])
month = int(s[1])
day = int(s[2])
total = 0
if month > 1:
    total += 31
if month > 2:
    if year % 4 == 0 and year % 100 != 0 or year % 400 == 0:
        total += 29
    else:
        total += 28
if month > 3:
    total += 31
if month > 4:
    total += 30
if month > 5:
    total += 31
if month > 6:
    total += 30
elif month > 7:
    total += 31
if month > 8:
    total +=31
if month > 9:
    total += 30
if month > 10:
    total += 31
if month > 11:
    total += 30
total += day
print(total)